<template>
  <div>
    <com-field-table-list :head="head" :row="row"></com-field-table-list>
  </div>
</template>
<script>
export  default  {
  props:{
    row:{},
    editable:{}
  },
  data(){

    return {
      childStore:{
          vc:this,
          name:'failCount'
      },

    }
  },
  computed:{
    mydata(){
      return this.row.fail_content
    },
    head(){
      var ctx = named_ctx['quality.fail_content_ctx']
     var inn_head = {
        name:'fail_content',
            readonly:!this.editable,
          'table_heads':[
        {name:'abstract',label:'不良简述',
          editor:'com-table-pop-fields-local',
          inn_editor:'com-table-mapper',
          options:ctx.abstract_options},
        {name:'count',label:'数量'},
        {name:'fail_kind',label:'不良分类',editor:'com-table-mapper',options:ctx.fail_kind_options},
        {name:'process_kind',label:'处理方案',editor:'com-table-mapper',options:ctx.process_schem_options},
        {name:'founder',label:'发现人员',editor: 'com-table-span',}
      ],
          'fields_heads':[
        {name:'abstract',label:'不良简述',editor:'com-field-select',options:ctx.abstract_options,
          required: true,
          readonly:!this.editable},
        {name:'count',label:'数量',editor:'com-field-int',required:true,readonly:!this.editable},
        {name:'detail_desp',label:'详细描述',editor:'com-field-blocktext',readonly:!this.editable},

        // 成品才展示
        {name:'founder',label:'发现人员',editor: 'com-field-linetext',readonly:!this.editable},
        {name:'prodmodel_name',label:'品名',editor: 'com-field-pop-table-select',
          table_ctx:named_ctx['ProdModelPicker'],
          type_input:true,
          width:'180px',
          after_select_express:`
            scope.row.prodmodel_no=scope.selected_row.no;
            scope.row.prodmodel_name=scope.selected_row.name;
            scope.row.prodmodel_specification=scope.selected_row.specification`,
          show_express: 'var ps= ex.vueParStore( scope.par_vc.ctx.genVc);rt=ps.vc.row.kind==5',
          readonly:!this.editable },
        {name:'prodmodel_no',label:'品号',editor: 'com-field-linetext',
          show_express: 'var ps= ex.vueParStore( scope.par_vc.ctx.genVc);rt=ps.vc.row.kind==5',
          readonly:!this.editable },
        {name:'prodmodel_specification',label:'规格',editor: 'com-field-linetext',
          show_express: 'var ps= ex.vueParStore( scope.par_vc.ctx.genVc);rt=ps.vc.row.kind==5',
          readonly:!this.editable },

        // 创建的时候不展示
        {name:'process_kind',label:'处理方案',editor:'com-field-select',show_express:'!scope.row.added',
          options:ctx.process_schem_options,readonly:!this.editable || !this.row.can_edit_solution },
        {name:'fail_kind',label:'不良分类',editor:'com-field-select',show_express:'!scope.row.added',
          options:ctx.fail_kind_options,readonly:!this.editable || !this.row.can_edit_solution },
        {name:'tech_advice',label:'技术意见',editor:'com-field-blocktext',show_express:'!scope.row.added',
          readonly:!this.editable || !this.row.can_edit_solution},
        {name:'tech_correct_action',label:'纠正预防措施',editor:'com-field-blocktext',show_express:'!scope.row.added',
          readonly:!this.editable || !this.row.can_edit_solution},


      ],
          preset_express:'rt={added:true}',
          after_save_express:`if(scope.row.added){delete scope.row.added}`
      }
      return inn_head
    }
  },
  watch:{

    mydata(nv){
      console.log(nv)
      cfg.show_load()
      ex.director_call('d.save_row',{row:this.row}).then((resp)=>{

        cfg.hide_load()
        // this.row.fail_count = resp.row.fail_count

      })
    }
  }
}
</script>